package drds.configuration.web.jstl;


import drds.configuration.configuration.ConfigUtil;
import drds.configuration.mvc.util.WebApp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;
import java.util.Properties;


public class Set implements Tag {

    private PageContext pageContext;

    public int doStartTag() throws JspException {
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
        WebApp.setCharacterEncoding(request, response);
        request.setAttribute("__ROOT__", WebApp.getWebRootPath(request));
        request.setAttribute("__PUBLIC__", WebApp.getPublicPath(request));
        request.setAttribute("__ADMIN__", WebApp.getWebRootPath(request) + "/jsp/__admin__/");
        //共享资源文件
        Properties properties = ConfigUtil.getPropertiesInConfigPath("web.common.properties");
        String drds_share_resource = properties.getProperty("drds.share.resource");
        request.setAttribute("drds_share_resource", drds_share_resource);
        request.setAttribute("material_pro_resource_path", drds_share_resource + properties.getProperty("material_pro.resource_path"));
        return 0;
    }

    public int doEndTag() throws JspException {
        return 0;
    }

    public Tag getParent() {
        return null;
    }

    public void setParent(Tag arg0) {
    }

    public void release() {
    }

    public void setPageContext(PageContext arg0) {
        this.pageContext = arg0;
    }
}